/**
 * StarInfoFrameUnexplored.java
 *
 * Roslan's Remake of MOO in 3D using Ardor3D
 * (C) 2011 Roslan Amir. All rights reserved.
 */

package com.roslan.games.moo3d.ui.hud;

import com.ardor3d.extension.ui.UILabel;
import com.ardor3d.extension.ui.UIPanel;
import com.ardor3d.extension.ui.backdrop.ImageBackdrop;
import com.ardor3d.extension.ui.util.SubTex;
import com.ardor3d.image.Texture;
import com.ardor3d.util.TextureManager;
import com.roslan.games.moo3d.data.Star;
import com.roslan.games.moo3d.spatial.StarNode;

/**
 * This Panel displays the information about the currently selected Star which has not been explored.
 * 
 * @author Roslan Amir
 * @version 1.0 - Jan 10, 2011
 */
public class StarInfoFrameUnexplored extends StarInfoFrameBase {

	/**
	 * 
	 */
	private static final String IMAGE_UNEXPLORED_YELLOW = "images/unexplored-yellow.jpg";
	private static final String IMAGE_UNEXPLORED_GREEN = "images/unexplored-green.jpg";
	private static final String IMAGE_UNEXPLORED_RED = "images/unexplored-red.jpg";
	private static final String IMAGE_UNEXPLORED_WHITE = "images/unexplored-white.jpg";
	private static final String IMAGE_UNEXPLORED_BLUE = "images/unexplored-blue.jpg";
	private static final String IMAGE_UNEXPLORED_NEUTRON = "images/unexplored-neutron.jpg";

	/**
	 * 
	 */
	private static final ImageBackdrop[] BACKDROP_STAR_DESCRIPTION = new ImageBackdrop[Star.STAR_DESCRIPTION.length];

	/*
	 * Load the image textures.
	 */
	static {
		/*
		 * Load the image subtextures and create the backdrops.
		 */
		Texture tex = TextureManager.load(IMAGE_UNEXPLORED_YELLOW, Texture.MinificationFilter.Trilinear, false);
		BACKDROP_STAR_DESCRIPTION[0] = new ImageBackdrop(new SubTex(tex));
		tex = TextureManager.load(IMAGE_UNEXPLORED_GREEN, Texture.MinificationFilter.Trilinear, false);
		BACKDROP_STAR_DESCRIPTION[1] = new ImageBackdrop(new SubTex(tex));
		tex = TextureManager.load(IMAGE_UNEXPLORED_RED, Texture.MinificationFilter.Trilinear, false);
		BACKDROP_STAR_DESCRIPTION[2] = new ImageBackdrop(new SubTex(tex));
		tex = TextureManager.load(IMAGE_UNEXPLORED_WHITE, Texture.MinificationFilter.Trilinear, false);
		BACKDROP_STAR_DESCRIPTION[3] = new ImageBackdrop(new SubTex(tex));
		tex = TextureManager.load(IMAGE_UNEXPLORED_BLUE, Texture.MinificationFilter.Trilinear, false);
		BACKDROP_STAR_DESCRIPTION[4] = new ImageBackdrop(new SubTex(tex));
		tex = TextureManager.load(IMAGE_UNEXPLORED_NEUTRON, Texture.MinificationFilter.Trilinear, false);
		BACKDROP_STAR_DESCRIPTION[5] = new ImageBackdrop(new SubTex(tex));
	}

	/**
	 * The label for the star's range from the nearest player's colony.
	 */
	protected final UILabel rangeValueLabel;

	/**
	 * Default no-arg constructor.
	 */
	public StarInfoFrameUnexplored() {
		super("Unexplored Star System", null);

		final UIPanel panel = new UIPanel();
		// panel.setLayout(new AnchorLayout());
		panel.setMargin(HudManager.MARGINS_ZERO);
		panel.setPadding(HudManager.PADDING_2000);
		panel.setBorder(HudManager.SOLID_BORDER_TWO);
		infoPanel.add(panel);

		rangeValueLabel = new UILabel("");
		rangeValueLabel.setStyledText(true);
		// rangeValueLabel.setForegroundColor(DEFAULT_FOREGROUND_COLOR);
		// rangeValueLabel.setLayoutData(new AnchorLayoutData(Alignment.TOP_LEFT, panel, Alignment.TOP_LEFT, 7, -135));
		panel.add(rangeValueLabel);
	}

	/**
	 * Update the information to the currently selected Star (or Colony).
	 * 
	 * @param starNode - the Star (or Colony) whose info is to be upadated
	 */
	@Override
	public void update(StarNode starNode) {
		infoPanel.setBackdrop(BACKDROP_STAR_DESCRIPTION[starNode.getStar().colorIndex]);
		rangeValueLabel.setText("[b][c=#fff]Range: " + starNode.range + " parsecs[/c][/b]");
		// rangeValueLabel.setText("[c=#fff]Range: " + starNode.range + " parsecs[/c]");
		updateAndpack();
	}

}
